<template>
  <div class="adminmodule mb-20">
    <div class="mycenter-in-user-list mr-10 admincorner">
      <p class="add-box-theme"><span></span>实时看板（餐品管理）</p>
      <div class="add-box-theme-box">
        <div class="add-box-theme-box-list" @click="pathPushAdd(1)">
          <i class="add-box-theme-box-list-icon iconfont iconfaburenwu"></i>
          <span>添加餐品</span>
        </div>
        <div class="add-box-theme-box-list" @click="pathPushAdd(2)">
          <i class="add-box-theme-box-list-icon iconfont icontianjiarenyuan"></i>
          <span>添加类目</span>
        </div>
        <div class="add-box-theme-box-list" @click="pathPushAdd(3)">
          <i class="add-box-theme-box-list-icon iconfont iconwenjuan1"></i>
          <span>发起点评</span>
        </div>
        <div class="add-box-theme-box-list" @click="pathPushAdd(4)">
          <i class="add-box-theme-box-list-icon iconfont iconwenjuan1"></i>
          <span>点评记录</span>
        </div>
        <div class="add-box-theme-box-list" @click="pathPushAdd(5)">
          <i class="add-box-theme-box-list-icon iconfont iconwenjuan1"></i>
          <span>评价统计</span>
        </div>
      </div>
    </div>
    <div class="adminmodule-c">
      <div class="adminmodule-c-tab">
        <span class="active">校园餐品（{{flooretotal}}）</span>
        <!--<span>超时书籍（10）</span>-->
      </div>
      <div class="adminmodule-c-body">
        <div class="adminmodule-c-body-title">
          <span class="adminmodule-c-f">展示图</span>
          <span class="adminmodule-c-f">菜品名称</span>
          <span class="adminmodule-c-f">菜品类目</span>
          <span class="adminmodule-c-f">上架时间</span>
        </div>
        <div class="adminmodule-c-body-list" v-for="(item,index) in arryList" v-if="index<3"  @click="pathPushAdd(1)">
          <span class="adminmodule-c-f">
            <span :style="{backgroundImage:'url('+item.pic+')',backgroundSize:'cover',backgroundPosition:'center'}" class="foodShowImg"></span>
          </span>
          <span class="adminmodule-c-f">{{item.name}}</span>
          <span class="adminmodule-c-f">{{item.catName}}</span>
          <span class="adminmodule-c-f">{{item.create_time}}</span>
        </div>
        <div class="adminmodule-c-body-more"><span  @click="pathPushAdd(1)">查看更多<i class="el-icon-d-arrow-right"></i></span></div>
      </div>
    </div>
  </div>
</template>

<script>
  import {yeartime} from '@/utils/util.js'

  export default {
    props: ['statisticsData'],
    name: 'powerMateriel',
    data () {
      return {
        arryList: [], // 数据列表
        flooretotal: 0
      }
    },
    created () {
      this.InitFn()
    },
    methods: {
      // 初始化
      InitFn () {
        this.$post(this.api.food_list, {
          p: 1,
          name: '',
          cat_id: 0
        }).then((response) => {
          if (response.code === 0) {
            for (let i in response.list.data) {
              response.list.data[i].create_time = yeartime(response.list.data[i].create_time)
            }
            this.arryList = response.list.data
            this.flooretotal = response.list.total
          } else {
          }
        }).catch((err) => {
          console.log(err)
        })
      },
      pathPushAdd (option) {
        let path = ''
        if (option === 1) {
          path = '/foodList'
        } else if (option === 2) {
          path = '/cateList'
        } else if (option === 3) {
          path = '/buildComment'
        } else if (option === 4) {
          path = '/CommentList'
        } else if (option === 5) {
          path = '/Statistics'
        }
        this.$router.push(path)
      }
    }
  }
</script>
